import HTMLTestRunner_cn,yagmail,logging,time

class Tools():
    def Log(self):
        st = time.strftime('%Y%m%d%H%M', time.localtime())
        log = logging.basicConfig(level=logging.DEBUG,
                                  format='%(levelname)s %(message)s %(filename)s %(asctime)s %(lineno)d ',
                                  filename='A3mall.log',
                                  filemode='a+')
        return log

    def html(self):
        st = time.strftime('%Y%m%d%H%M', time.localtime())
        report = HTMLTestRunner_cn.HTMLTestRunner(open('A3mall.html','wb'),
                                                  title='测试报告',
                                                  description='测试报告')
        return report

    def email(self,file):
        email = yagmail.SMTP(user='2031077871@qq.com',password='fzacgbiwqslydecf',host='smtp.qq.com')
        email.send(to='2031077871@qq.com',subject='测试结果',contents='测试结果',attachments=file)
        email.close()